package flex.business
{
	
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import flash.events.Event;
	import flash.utils.setTimeout;
	
	import flex.serviceLocator.UserServicelocator;
	import flex.vo.UserVO;
	
	import mx.events.PropertyChangeEvent;
	import mx.rpc.AsyncToken;
	import mx.rpc.Fault;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	

	public class UserDelegate
	{
		private var responder:IResponder;
		private var remoteObject:RemoteObject;
		
		public function UserDelegate(responder:IResponder)
		{
			this.responder = responder;
		}
		
		public function login(userVO:UserVO):void
		{
			trace("————————————————————进入UserDelegate的login方法——————————————————————");
			remoteObject = ServiceLocator.getInstance().getRemoteObject("userBiz");
			remoteObject.login(userVO);
			//用send方法实现的是异步处理方式，同样可以获得返回值，但有什么后果还不清楚
//			remoteObject.getOperation("login").send(userVO);
			remoteObject.addEventListener(ResultEvent.RESULT,OnResult);
			
		}
		

		
		private function OnResult(event:ResultEvent):void
		{
			trace("————————————————————进入UserDelegate的OnResult了——————————————————————");
			var rollBack:UserVO = new UserVO();
			rollBack = event.result as UserVO;
//			进入到UserCommand的result方法
			responder.result(rollBack);
		}
		
		
		
	}
}